package com.qf.wangqing.sportsnews.bean.cornpetition;

import android.databinding.BindingAdapter;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.qf.wangqing.sportsnews.R;
import com.squareup.picasso.Picasso;

/**
 * Created by Administrator on 2016/12/17.
 */

public class CornpetitionBindings {
    @BindingAdapter("loadUrl")
    public static void loadImage(ImageView view, String url) {
        Log.d("1620", "losdImage: " + "http://roi.skst.cn/logo/" + url);
        Log.d("1620", "loadImage: " + url);
        Picasso.with(view.getContext())
                .load(url)
                .transform(new CircleTransformation())
                .into(view);
        Log.d("1620", "losdImage: " + "http://roi.skst.cn/logo/" + url);

    }

    @BindingAdapter("showImage")
    public static void showImage(ImageView view, String time) {
        if (time != null) {
            if (time.equals("0")) {
                view.setImageResource(R.mipmap.alarm_no);

            } else {
                if(time.equals("0")){
                    view.setVisibility(View.INVISIBLE);
                }

            }


        }
    }
    @BindingAdapter("showTimeText")
    public static void showTime(TextView view,String time){
        if (time != null) {
            if (time.equals("-1")) {
                view.setText("已结束");
             } else {
                if (time.equals("0")) {
                    view.setVisibility(View.INVISIBLE);

                }
            }


        }
    }
    @BindingAdapter("scoreText")
    public static void scoreText(TextView view,String time,String  score){
        if(time!=null  && score!=null){
            if(!time.equals("-1") && !time.equals("0") ){
                view.setText(score);
                view.setTextColor(Color.RED);
            }
        }

    }



}
